from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
from common.ReadConfig import ConfigReader
base_path = ConfigReader('config.ini').get_value('dev_base_url')
class TestCaseLogin(HttpRunner):
    config = Config("testcase description").base_url(base_path).verify(False)
    teststeps = [
            Step(
                RunRequest("登录").
                 post("/adminapi/login").
                 with_json({'account': 'admin', 'pwd': '123456'}).
                 extract().
                 with_jmespath("body.data.token",'token').      # 取出来token
                 validate().
                 assert_equal("status_code", 200).
                 assert_equal('headers."Content-Type"', "application/json; charset=utf-8").
                 assert_equal("body.status", 200).
                 assert_equal("body.msg", "success")),
    ]
if __name__ == "__main__":
    TestCaseLogin().test_start()
